package dfbz.com.filter;

//@WebFilter(urlPatterns = "/student/*",dispatcherTypes = {DispatcherType.FORWARD, DispatcherType.REQUEST})
//public class myFilter implements Filter {
//    @Override
//    public void init(FilterConfig filterConfig) throws ServletException {
//
//    }
//
//    @Override
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        System.out.println("进来了这里，被拦截了");
//        HttpServletRequest req = (HttpServletRequest) servletRequest;
//        HttpServletResponse resp = (HttpServletResponse) servletResponse;
//        HttpSession session = req.getSession();
//        Object mag = session.getAttribute("user");
//        if (mag!=null){
//            //登录成功过的，放行，重新设置session时间
//            filterChain.doFilter(servletRequest,servletResponse);
//            req.getSession().setMaxInactiveInterval(Constance.MAX_SESSION_TIME);
//        }else {
//            //没有登录过的或登录失效的，跳回登录页面
//            resp.sendRedirect(req.getContextPath()+"/index.jsp");
//        }
//
//    }
//
//    @Override
//    public void destroy() {
//
//    }
//}
